<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>Document</title>
	<style type="text/css">
	   #box{
	   	    margin: 0 auto;
	   	    width: 350px;
	   }
	   #but{
	   	    margin-top: 10px;
	   }
	</style>
	<script type="text/javascript">
		window.onload = function() {
			var Obut = document.getElementById("but");
			Obut.onclick = function() {
			    var OVa = document.getElementById("value");
			    var StrArr = OVa.value.split(",");
			    var totalNum = 0;
			    for (var i = 0; i < StrArr.length; i++) {
				    totalNum += parseInt(StrArr[i]);
			    }
			    // alert(totalNum)
			    var Op = document.getElementsByTagName("p")[0];
			    Op.innerHTML=totalNum;
			}
		}
	</script>
</head>
<body>
	<div id="box">
		<input type="text" value="1,2,3,4,5,4,3,2,1" id="value">
		 <br>
	    <input type="button" value="求和" id="but"> 
         <p></p>
	</div>
</body>
</html>